<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>文章类别管理</title>
  <!-- 导入CSS -->
  <link rel="stylesheet" href="../../lib/layui/css/layui.css">
  <link rel="stylesheet" href="../../css/article/article-cate.css">
</head>

<body>
  <!-- 卡片区域 -->
  <div class="layui-card">
    <div class="layui-card-header">
      文章类别管理
      <button id="add-cate-btn" class="layui-btn layui-btn-normal layui-btn-sm">添加类别</button>
    </div>
    <div class="layui-card-body">
      <!-- 表格内容 -->
      <table class="layui-table">
        <!-- 通过colgroup调节表格列 -->
        <colgroup>
          <col width="100" />
          <col />
          <col />
          <col width="200" />
        </colgroup>
        <thead>
          <tr>
            <th>序号</th>
            <th>分类名称</th>
            <th>分类别名</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody></tbody>
      </table>
    </div>
  </div>

  <!-- 表格内容模板 -->
  <script type="text/html" id="tbody-tmp">
    {{each data item}}
      <tr>
        <td>{{$index + 1}}</td>
        <td>{{item.name}}</td>
        <td>{{item.alias}}</td>
        <td>
          <button class="edit-cate-btn layui-btn layui-btn-sm" data-id="{{item._id}}">编辑</button>
          <button class="delete-cate-btn layui-btn layui-btn-danger layui-btn-sm" data-id="{{item._id}}">删除</button>
        </td>
      </tr>
    {{/each}}
  </script>

  <!-- 新增类别弹窗模板 -->
  <script type="text/html" id="add-cate-tmp">
    <div class="layer-model">
      <form id="addForm" class="layui-form" lay-filter="add-cate-form">
        <!-- 表单元素 -->
        <div class="layui-form-item">
          <label class="layui-form-label">分类名称</label>
          <div class="layui-input-block">
            <input type="input" name="name" class="layui-input" lay-verify="required" placeholder="请输入分类名称">
          </div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label">分类别名</label>
          <div class="layui-input-block">
            <input type="input" name="alias" class="layui-input" lay-verify="required" placeholder="请输入分类别名">
          </div>
        </div>

        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit >确定添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
          </div>
        </div>
      </form>
    </div>
  </script>

  <!-- 修改类别弹窗模板 -->
  <script type="text/html" id="edit-cate-tmp">
    <div class="layer-model">
      <form id="editForm" class="layui-form" lay-filter="edit-cate-form">
        <!-- 表单元素 -->
        <div class="layui-form-item">
          <label class="layui-form-label">分类名称</label>
          <div class="layui-input-block">
            <input type="input" name="name" class="layui-input" lay-verify="required" placeholder="请输入分类名称">
          </div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label">分类别名</label>
          <div class="layui-input-block">
            <input type="input" name="alias" class="layui-input" lay-verify="required" placeholder="请输入分类别名">
          </div>
        </div>

        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit >确定修改</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
          </div>
        </div>
      </form>
    </div>
  </script>

  <!-- 导入JS -->
  <script src="../../lib/layui/layui.all.js"></script>
  <script src="../../lib/jquery.js"></script>
  <script src="../../lib/template-web.js"></script>
  <script src="../..//js/BASE_API.js"></script>
  <script src="../../js/article/article-cate.js"></script>
</body>

</html>